<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>

    <script>
        function changetab(title){
            var url="";
            switch (title) {
                case 'doctortable':
                    url="./doctors/doctorList.html";
                    break;

                case 'Bar':
                    url="./students/Bar.html";
                    break;
                case 'patientList':
                    url="./patient/patientList.html";
                    break;

                    case 'nurse':
                    url="./nurse/nurseList.html";
                    break;
					
					case 'departmentlist':
                    url="./departments/departmentList.html";
                    break;

					case 'prescription':
                    url="./prescription/preList.html";
                    break;
					
                default:
                    break;
            }

            $("#main").attr("src",url);
        }
    </script>

</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black"><img src="./images/logo.png" width="170px" height="100px" style="margin-top: -20px;"/></div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>

            <li class="layui-nav-item layui-hide-xs"><a href="">个人信息</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">考勤记录</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">接诊病人</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                    <span id="currentUser"></span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="index.html">退出账号</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">就诊管理</a>
                    <dl class="layui-nav-child">
                        <dd ><a href="javascript:;" onclick="changetab('doctortable')">医生列表</a></dd>
                        <!-- <dd ><a href="javascript:;" onclick="changetab('Bar')">统计信息</a></dd> -->
                        <dd><a href="javascript:;" onclick="changetab('patientList')" >病人管理</a></dd>
                        <!-- <dd><a href="javascript:;" onclick="changetab('nurse')" >值班护士</a></dd> -->
                    </dl>
                </li>
				
				<li class="layui-nav-item">
                    <a href="javascript:;" onclick="changetab('departmentlist')" >科室管理</a>
                </li>
				
                <li class="layui-nav-item">
                    <a href="javascript:;">药品管理</a>
                    <!-- <dl class="layui-nav-child">
                        <dd><a href="javascript:;">中药</a></dd>
                        <dd><a href="javascript:;">西药</a></dd>
                    </dl> -->
                </li>
               <li class="layui-nav-item"><a href="javascript:;">处方管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="changetab('prescription')">处方列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="">关于我们</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <iframe id="main" src="welcome.html" frameborder="0" style="width: 100%; height: 600px;"></iframe>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        版权所有@java2201
    </div>
</div>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        var token = JSON.parse(localStorage.getItem("token"));
        $.ajaxSetup({
            // 发送cookie
            xhrFields: {
                withCredentials: true
            },
            headers: {
                "token": token
            }
        })

        // 从本地存储 把当前用户数据 取出来  并转为  js 对象
        var data = JSON.parse(localStorage.getItem("currentUser"));
        console.log(data);
        //alert(data.username);


        $("#currentUser").html(data.name);

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });

    });
</script>
</body>
</html>